import Operator from "./Operator";
import { RC } from "../config/RC";
import MessageBox from "../entities/MessageBox";
import Users from "../entities/User";
import Group from "../entities/Group";
import {USER} from "../config/config";

class GetUserOrGroupNameOperation extends Operator {
    public async execute(): Promise<RC> {
        const Id = this.args.getProperty('Id');
        

        const userName = await Users.getName(Id);
        const groupName = await Group.getName(Id);
        if(userName != ""){
            this.args.setProperty('Name', userName);
            this.args.setProperty('type',"user")
        }else if(groupName != "")
        {
            this.args.setProperty('Name', groupName);
            this.args.setProperty('type',"group")
        }else{
            this.args.setProperty('Name', "null");
            this.args.setProperty('type',"null")
        }
        
        
        return RC.SUCCESS;
    }
}

export default GetUserOrGroupNameOperation;
